<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">

  <!-- PACE Progress Bar START -->
  
  

  <!-- PACE Progress Bar START -->

  
  <title>
    
    速度up！python/ubuntu/nodejs/树莓派等更换国内源汇总 |
    
    ex2tron&#39;s Tech Blog
  </title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  <meta name="keywords" content="ex2tron,opencv,tensorflow" />
  
  
  
  
  <meta name="description" content="在Python/Linux/Node.js开发中，要经常下载各种各样的的包，然而由于默认的安装源大部分是在国外的服务器上，所以下载速度嘛……">
<meta name="keywords" content="Python,Ubuntu,NodeJS,pip,nmp,apt">
<meta property="og:type" content="article">
<meta property="og:title" content="速度UP！Python&#x2F;Ubuntu&#x2F;NodeJS&#x2F;树莓派等更换国内源汇总">
<meta property="og:url" content="http://ex2tron.wang/python-ubuntu-nodejs-change-sources/index.html">
<meta property="og:site_name" content="ex2tron&#39;s Tech Blog">
<meta property="og:description" content="在Python/Linux/Node.js开发中，要经常下载各种各样的的包，然而由于默认的安装源大部分是在国外的服务器上，所以下载速度嘛……">
<meta property="og:locale" content="en">
<meta property="og:image" content="http://pic.ex2tron.top/python_ubuntu_node_change_source_cover3.jpg">
<meta property="og:updated_time" content="2019-05-27T02:12:58.442Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="速度UP！Python&#x2F;Ubuntu&#x2F;NodeJS&#x2F;树莓派等更换国内源汇总">
<meta name="twitter:description" content="在Python/Linux/Node.js开发中，要经常下载各种各样的的包，然而由于默认的安装源大部分是在国外的服务器上，所以下载速度嘛……">
<meta name="twitter:image" content="http://pic.ex2tron.top/python_ubuntu_node_change_source_cover3.jpg">
  
  <link rel="alternate" href="/atom.xaml" title="ex2tron&#39;s Tech Blog" type="application/atom+xml">
  
  <link rel="icon" href="/img/bookshelf.ico">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans|Montserrat:700" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic" rel="stylesheet" type="text/css">
  <link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
  <style type="text/css">
    @font-face {
      font-family: futura-pt;
      src: url(https://use.typekit.net/af/9749f0/00000000000000000001008f/27/l?subset_id=2&fvd=n5) format("woff2");
      font-weight: 500;
      font-style: normal;
    }

    @font-face {
      font-family: futura-pt;
      src: url(https://use.typekit.net/af/90cf9f/000000000000000000010091/27/l?subset_id=2&fvd=n7) format("woff2");
      font-weight: 500;
      font-style: normal;
    }

    @font-face {
      font-family: futura-pt;
      src: url(https://use.typekit.net/af/8a5494/000000000000000000013365/27/l?subset_id=2&fvd=n4) format("woff2");
      font-weight: lighter;
      font-style: normal;
    }

    @font-face {
      font-family: futura-pt;
      src: url(https://use.typekit.net/af/d337d8/000000000000000000010095/27/l?subset_id=2&fvd=i4) format("woff2");
      font-weight: 400;
      font-style: italic;
    }
  </style>

  <link rel="stylesheet" id="athemes-headings-fonts-css" href="//fonts.googleapis.com/css?family=Yanone+Kaffeesatz%3A200%2C300%2C400%2C700&amp;ver=4.6.1"
    type="text/css" media="all">
  <link rel="stylesheet" href="/css/style.css">

  <script src="/js/jquery-3.1.1.min.js"></script>

  <!-- Bootstrap core CSS -->
  <link rel="stylesheet" href="/css/bootstrap.css">
  <link rel="stylesheet" href="/css/hiero.css">
  <link rel="stylesheet" href="/css/glyphs.css">
  
  <link rel="stylesheet" href="/css/vdonate.css">
  

  <!-- Custom CSS -->
  <link rel="stylesheet" href="/css/my.css">

  <script>
    (function () {
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      }
      else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>

</head>
<script>
var themeMenus = {};

  themeMenus["/"] = "Home"; 

  themeMenus["/archives"] = "Archives"; 

  themeMenus["/categories"] = "Categories"; 

  themeMenus["/tags"] = "Tags"; 

  themeMenus["/about"] = "About"; 

</script>


  <body data-spy="scroll" data-target="#toc" data-offset="50">


  <header id="allheader" class="site-header" role="banner">
  <div class="clearfix container">
      <div class="site-branding">

          <h1 class="site-title">
            
              <a href="/" title="ex2tron&#39;s Tech Blog" rel="home"> ex2tron&#39;s Tech Blog </a>
            
          </h1>

          
            
          <nav id="main-navigation" class="main-navigation" role="navigation">
            <a class="nav-open">Menu</a>
            <a class="nav-close">Close</a>
            <div class="clearfix sf-menu">

              <ul id="main-nav" class="nmenu sf-js-enabled">
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/">Home</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/archives">Archives</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/categories">Categories</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/tags">Tags</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/about">About</a> </li>
                    
              </ul>
            </div>
          </nav>


      </div>
  </div>
</header>




  <div id="container">
    <div id="wrap">
            
      <div id="content" class="outer">
        
          <section id="main" style="float:none;"><article id="post-速度UP！PythonUbuntuNodeJS树莓派等更换国内源汇总" style="width: 66%; float:left;" class="article article-type-post" itemscope itemprop="blogPost" >
  <div id="articleInner" class="clearfix post-1016 post type-post status-publish format-standard has-post-thumbnail hentry category-template-2 category-uncategorized tag-codex tag-edge-case tag-featured-image tag-image tag-template">
    
<div class="article-gallery">
  <div class="article-gallery-photos">
    
      <a class="article-gallery-img fancybox" href="http://pic.ex2tron.top/python_ubuntu_node_change_source_cover3.jpg" rel="gallery_cjxj6dyhc00bq5w59ma6cxnx4">
        <img src="http://pic.ex2tron.top/python_ubuntu_node_change_source_cover3.jpg" itemprop="image">
      </a>
    
  </div>
</div>

    
      <header class="article-header">
        
  
    <h1 class="thumb" class="article-title" itemprop="name">
      速度UP！Python/Ubuntu/NodeJS/树莓派等更换国内源汇总
    </h1>
  

      </header>
    
    <div class="article-meta">
      
	Posted on <a href="/python-ubuntu-nodejs-change-sources/" class="article-date">
	  <time datetime="2019-03-21T07:08:09.000Z" itemprop="datePublished">March 21, 2019</time>
	</a>

      
	<!-- TODO: ex2tron.wang 启用但暂时不显示访问量 2019年3月20日 -->
	<!-- <span id="busuanzi_container_page_pv">
	  本文总阅读量<span id="busuanzi_value_page_pv"></span>次
	</span> -->

    </div>
    <div class="article-entry" itemprop="articleBody">
      
        <p>在Python/Linux/Node.js开发中，要经常下载各种各样的的包，然而由于默认的安装源大部分是在国外的服务器上，所以下载速度嘛……<a id="more"></a></p>
<blockquote>
<p><em>You‘ll never win with violence, Tony, you only win when you maintain your dignity.</em>  ——<a href="https://movie.douban.com/subject/27060077/" target="_blank" rel="external">《Green Book》</a><br><br><em>暴力永远无法取胜，托尼，只有坚守尊严才会赢。</em>——<a href="https://movie.douban.com/subject/27060077/" target="_blank" rel="external">《绿皮书》</a></p>
<p><strong>友情广告：电影台词分享网站：<a href="http://moviequotes.ex2tron.wang/" target="_blank" rel="external">MovieQuotes</a></strong></p>
</blockquote>
<hr>
<p>有时真的是很捉急呀，所以学会更改安装源还是很有必要滴……Python默认源：<a href="https://pypi.org/" target="_blank" rel="external">https://pypi.org/</a>，Ubuntu默认源：<a href="http://mirrors.ubuntu.com/" target="_blank" rel="external">http://mirrors.ubuntu.com/</a>，Node默认源：<a href="http://registry.npmjs.org" target="_blank" rel="external">http://registry.npmjs.org</a>。</p>
<h2 id="Python-pip更换源"><a href="#Python-pip更换源" class="headerlink" title="Python/pip更换源"></a>Python/pip更换源</h2><h3 id="更换前后速度对比"><a href="#更换前后速度对比" class="headerlink" title="更换前后速度对比"></a>更换前后速度对比</h3><p>具体速度提升跟网络也有关系，不过一般来说，提升还是相当明显的：</p>
<p><img src="http://pic.ex2tron.top/python_ubuntu_node_before_change.jpg" alt="默认源，这速度够我出去旅游一趟了(。﹏。)"></p>
<p><img src="http://pic.ex2tron.top/python_ubuntu_node_after_change.jpg" alt="清华大学源"></p>
<h3 id="常用国内源"><a href="#常用国内源" class="headerlink" title="常用国内源"></a>常用国内源</h3><ul>
<li>清华大学：<a href="https://pypi.tuna.tsinghua.edu.cn/simple/" target="_blank" rel="external">https://pypi.tuna.tsinghua.edu.cn/simple/</a> | <a href="https://mirror.tuna.tsinghua.edu.cn/help/pypi/" target="_blank" rel="external">pypi镜像使用帮助</a></li>
<li>阿里巴巴：<a href="https://mirrors.aliyun.com/pypi/simple/" target="_blank" rel="external">https://mirrors.aliyun.com/pypi/simple/</a> </li>
<li>腾讯云：<a href="http://mirrors.cloud.tencent.com/pypi/simple/" target="_blank" rel="external">http://mirrors.cloud.tencent.com/pypi/simple/</a></li>
<li>豆瓣：<a href="https://pypi.doubanio.com/simple/" target="_blank" rel="external">https://pypi.doubanio.com/simple/</a></li>
</ul>
<h3 id="临时更改"><a href="#临时更改" class="headerlink" title="临时更改"></a>临时更改</h3><p>临时更换源只需要多加一个<code>-i</code>参数（i表示index索引），比如这里更换成清华源：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">pip install pkg -i https://pypi.tuna.tsinghua.edu.cn/simple</div></pre></td></tr></table></figure>
<h3 id="永久更改"><a href="#永久更改" class="headerlink" title="永久更改"></a>永久更改</h3><p>如果不想每次都这么麻烦的话，可以写入配置文件。新版的pip(&gt;=10.0.0)直接用下面一句话就行：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple</div><div class="line"><span class="meta">#</span><span class="bash"> 查看pip版本：pip --version</span></div></pre></td></tr></table></figure>
<p>执行后，Windows/Linux都会在用户目录生成pip配置文件，如我的Windows是在： <code>C:\Users\ex2tron\AppData\Roaming\pip\pip.ini</code>，Linux是在： <code>/home/ex2tron/.config/pip/pip.conf</code>。</p>
<p>如果是旧版的pip，可以手动新建上面两个文件，然后编辑内容为：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[global]</div><div class="line">index-url = https://pypi.tuna.tsinghua.edu.cn/simple</div></pre></td></tr></table></figure>
<p>配置文件也可以直接建在用户目录下，如Windows：<code>C:\Users\ex2tron\pip\pip.ini</code>，Linux：<code>/home/ex2tron/.pip/pip.conf</code>。保存后，照常<code>pip install pkg</code>即可。</p>
<h2 id="Ubuntu-apt更换源"><a href="#Ubuntu-apt更换源" class="headerlink" title="Ubuntu/apt更换源"></a>Ubuntu/apt更换源</h2><h3 id="图形界面配置（新手推荐）"><a href="#图形界面配置（新手推荐）" class="headerlink" title="图形界面配置（新手推荐）"></a>图形界面配置（新手推荐）</h3><p>如果使用的是Ubuntu的Desktop版本，更换起来就比较容易了：打开’软件和更新’，’下载自’这里选择’其他站点’：</p>
<p><img src="http://pic.ex2tron.top/python_ubuntu_node_change_ubuntu_source.png" alt=""></p>
<p>然后在弹出的界面中选择你要更换的服务器，比如这里更换为阿里云：</p>
<p><img src="http://pic.ex2tron.top/python_ubuntu_node_ubuntu_china_source.png" alt=""></p>
<p>点击’选择服务器’后需要验证密码，执行更新操作就可以了。</p>
<h3 id="手动配置"><a href="#手动配置" class="headerlink" title="手动配置"></a>手动配置</h3><p>如果是不带GUI的Ubuntu服务器，或是想装X，那么可以手动更换。更换源时跟Ubuntu系统的版本也有关系，这里我以Ubuntu 18.04和清华镜像为例，后面我写了个小脚本，方便不同版本的童鞋使用。</p>
<p>首先需要知道的是，Linux把源列表存在<code>/etc/apt/sources.list</code>里面，有兴趣可以看下其中内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">more /etc/apt/sources.list</div></pre></td></tr></table></figure>
<p>接下来更换方法都一样，很多开源镜像站官方也有说明，比如：</p>
<ul>
<li><a href="https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/" target="_blank" rel="external">清华大学Ubuntu镜像使用帮助</a></li>
<li><a href="http://mirrors.ustc.edu.cn/help/ubuntu.html" target="_blank" rel="external">中国科学技术大学Ubuntu镜像使用帮助</a></li>
<li><a href="https://opsx.alibaba.com/mirror?lang=zh-CN" target="_blank" rel="external">阿里云Ubuntu镜像使用帮助 点Ubuntu项右侧的帮助</a></li>
<li><a href="http://mirrors.163.com/.help/ubuntu.html" target="_blank" rel="external">网易Ubuntu镜像使用帮助</a></li>
</ul>
<p><img src="http://pic.ex2tron.top/python_ubuntu_node_tuna_tsinghua_help.jpg" alt=""></p>
<p>第一步：先将原有的备份：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak</div></pre></td></tr></table></figure>
<p>第二步：sudo编辑<code>sources.list文件</code>，修改其内容为镜像站提供的，如清华镜像站18.04：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"># 默认注释了源码镜像以提高 apt update 速度，如有需要可自行取消注释</div><div class="line">deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse</div><div class="line"># deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse</div><div class="line">deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse</div><div class="line"># deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse</div><div class="line">deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse</div><div class="line"># deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse</div><div class="line">deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse</div><div class="line"># deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse</div></pre></td></tr></table></figure>
<p>第三步：保存关闭后，执行更新索引的操作就可以了：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt update</div></pre></td></tr></table></figure>
<p>其实只要Ubuntu系统的版本代号对应起来就行。Ubuntu X.XX，第一个X代表年份，后两个X代表月份，一般4月份会发布LTS(<code>Long Term Support</code>)长期支持版本，常见的版本号和代码如下：</p>
<p>感兴趣的可以看<a href="#引用">引用</a>。</p>
<table>
<thead>
<tr>
<th style="text-align:center">版本</th>
<th style="text-align:center">代号</th>
<th style="text-align:center">日期</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">14.04 LTS</td>
<td style="text-align:center">Trusty Tahr / 可靠的塔尔羊</td>
<td style="text-align:center">2014年4月</td>
</tr>
<tr>
<td style="text-align:center">16.04 LTS</td>
<td style="text-align:center">Xenial Xerus / 好客的非洲地松鼠</td>
<td style="text-align:center">2016年4月</td>
</tr>
<tr>
<td style="text-align:center">18.04 LTS</td>
<td style="text-align:center">Bionic Beaver / 仿生海狸</td>
<td style="text-align:center">2018年4月</td>
</tr>
</tbody>
</table>
<h3 id="自动化脚本"><a href="#自动化脚本" class="headerlink" title="自动化脚本"></a>自动化脚本</h3><p>为了方便在Ubuntu常见的版本上更换源，我写了个自动化小脚本：<a href="https://github.com/ex2tron/MyLibsAndSamples/blob/master/016.Ubuntu%E8%87%AA%E5%8A%A8%E6%9B%B4%E6%8D%A2%E5%9B%BD%E5%86%85%E6%BA%90%28Shell%29/UbuntuAutoChangeSource.sh" target="_blank" rel="external">UbuntuAutoChangeSource.sh</a>。脚本会自动检测Ubuntu系统版本，然后选择你想更换的镜像源就可以了：</p>
<p><img src="http://pic.ex2tron.top/python_ubuntu_node_auto_scripts.gif" alt=""></p>
<h2 id="树莓派Raspbian"><a href="#树莓派Raspbian" class="headerlink" title="树莓派Raspbian"></a>树莓派Raspbian</h2><h3 id="常用源"><a href="#常用源" class="headerlink" title="常用源"></a>常用源</h3><p>树莓派支持的OS很多，经常用的也是官方推荐的是<a href="https://www.raspberrypi.org/downloads/" target="_blank" rel="external">Raspbian</a>。官网上有个镜像列表：<a href="http://www.raspbian.org/RaspbianMirrors" target="_blank" rel="external">http://www.raspbian.org/RaspbianMirrors</a>，国内常用：</p>
<ul>
<li>清华大学：<a href="http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/" target="_blank" rel="external">http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/</a> | <a href="https://mirror.tuna.tsinghua.edu.cn/help/raspbian/" target="_blank" rel="external">使用帮助</a></li>
<li>中国科学技术大学：<a href="http://mirrors.ustc.edu.cn/raspbian/raspbian/" target="_blank" rel="external">http://mirrors.ustc.edu.cn/raspbian/raspbian/</a> | <a href="http://mirrors.ustc.edu.cn/help/raspbian.html" target="_blank" rel="external">使用帮助</a></li>
</ul>
<h3 id="更换方法"><a href="#更换方法" class="headerlink" title="更换方法"></a>更换方法</h3><p>源列表同样存储在 <code>/etc/apt/sources.list</code>中，所以最好先备份下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak</div></pre></td></tr></table></figure>
<p>更换时也跟版本有关，比如基于Debian 9 Stretch构建的<code>Raspbian 2018-11-13</code>版本修改成清华大学的源（可将原先的用#注释掉，也可以覆盖修改，反正已经备份了）：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi</div><div class="line">deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi</div></pre></td></tr></table></figure>
<p>虽说跟版本有关，但基本上只要把源的地址改掉就好了。比如上面的修改方式也可以使用sed工具一键修改（针对<code>Raspbian 2018-04-19</code>后的版本）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo sed -i 's|raspbian.raspberrypi.org|mirrors.tuna.tsinghua.edu.cn/raspbian|g' /etc/apt/sources.list</div></pre></td></tr></table></figure>
<p>最后记得更新一下就好了：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt update</div></pre></td></tr></table></figure>
<h2 id="Node-js-npm更换源"><a href="#Node-js-npm更换源" class="headerlink" title="Node.js/npm更换源"></a>Node.js/npm更换源</h2><h3 id="临时更换"><a href="#临时更换" class="headerlink" title="临时更换"></a>临时更换</h3><p>国内最常用的npm镜像站是淘宝的：<a href="http://npm.taobao.org/" target="_blank" rel="external">http://npm.taobao.org/</a> 。临时更换就是加上<code>--registry</code>选项：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">npm install pkg --registry=https://registry.npm.taobao.org</div></pre></td></tr></table></figure>
<h3 id="永久更改-1"><a href="#永久更改-1" class="headerlink" title="永久更改"></a>永久更改</h3><p>类似于pip，可以直接使用<code>npm config</code>设置：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">npm config <span class="built_in">set</span> registry https://registry.npm.taobao.org</div></pre></td></tr></table></figure>
<p>验证有无生效：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">npm config get registry</div></pre></td></tr></table></figure>
<p>要恢复默认的话：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">npm config set registry http://registry.npmjs.org</div></pre></td></tr></table></figure>
<p>速度对比我就不放了，总之，各类包管理器，更换为国内的源之后，速度都会大幅提升。</p>
<h2 id="引用"><a href="#引用" class="headerlink" title="引用"></a>引用</h2><ul>
<li><a href="https://mirrors.tuna.tsinghua.edu.cn/" target="_blank" rel="external">清华大学开源镜像站</a></li>
<li><a href="https://opsx.alibaba.com/mirror" target="_blank" rel="external">阿里巴巴开源镜像站</a></li>
<li><a href="http://mirrors.163.com/" target="_blank" rel="external">网易开源镜像站</a></li>
<li><a href="http://mirrors.zju.edu.cn/" target="_blank" rel="external">浙江大学开源镜像站</a></li>
<li><a href="http://mirrors.ustc.edu.cn/" target="_blank" rel="external">中国科学技术大学开源镜像站</a></li>
<li><a href="https://npm.taobao.org/" target="_blank" rel="external">淘宝NPM镜像站</a></li>
<li><a href="https://github.com/ex2tron/MyLibsAndSamples/tree/master/016.Ubuntu%E8%87%AA%E5%8A%A8%E6%9B%B4%E6%8D%A2%E5%9B%BD%E5%86%85%E6%BA%90%28Shell%29" target="_blank" rel="external">本节源码</a></li>
<li><a href="https://wiki.ubuntu.com/DevelopmentCodeNames" target="_blank" rel="external">Ubuntu官网版本号及代号说明：DevelopmentCodeNames</a></li>
</ul>
<blockquote>
<p><em>生命不息，折腾不止，Excelsior!</em></p>
</blockquote>

      
    </div>
    <footer class="entry-meta entry-footer">
      
	<span class="ico-folder"></span>
    <a class="article-category-link" href="/categories/Build篇/">Build篇</a>

      
  <span class="ico-tags"></span>
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/NodeJS/">NodeJS</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Python/">Python</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Ubuntu/">Ubuntu</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/apt/">apt</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/nmp/">nmp</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/pip/">pip</a></li></ul>


      <div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a></div>
      <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{},"image":{"viewList":["qzone","tsina","weixin"],"viewText":"分享到：","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>

      
        <div id="donation_div"></div>

<script src="/js/vdonate.js"></script>
  <script>
    var a = new Donate({
      title: '谢谢支持，我会更加✊~', // 可选参数，打赏标题
      // btnText: 'Donate', // 可选参数，打赏按钮文字
      btnText: '赏', // 可选参数，打赏按钮文字
      el: document.getElementById('donation_div'),
      wechatImage: '/img/wechat.jpg',
      alipayImage: '/img/alipay.jpg'
    });
  </script>
      
                  
      
        
	<div id="comment">
		<!-- 来必力City版安装代码 -->
		<div id="lv-container" data-id="city" data-uid="MTAyMC8yOTQ4MS82MDQ5">
		<script type="text/javascript">
		   (function(d, s) {
		       var j, e = d.getElementsByTagName(s)[0];

		       if (typeof LivereTower === 'function') { return; }

		       j = d.createElement(s);
		       j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
		       j.async = true;

		       e.parentNode.insertBefore(j, e);
		   })(document, 'script');
		</script>
		<noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
		</div>
		<!-- City版安装代码已完成 -->
	</div>


      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/cloud-vultr-ss-vpn-enable-bbr/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          【云服务】起飞！Vultr 10分钟快速搭梯子并启用BBR加速
        
      </div>
    </a>
  
  
    <a href="/install-windows10-on-ubuntu/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">Ubuntu上安装Windows10双系统步骤及常见问题</div>
    </a>
  
</nav>

  
</article>

<!-- Table of Contents -->

  <aside id="sidebar">
    <div id="toc" class="toc-article">
    <strong class="toc-title">Contents</strong>
    
      <ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Python-pip更换源"><span class="nav-number">1.</span> <span class="nav-text">Python/pip更换源</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#更换前后速度对比"><span class="nav-number">1.1.</span> <span class="nav-text">更换前后速度对比</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#常用国内源"><span class="nav-number">1.2.</span> <span class="nav-text">常用国内源</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#临时更改"><span class="nav-number">1.3.</span> <span class="nav-text">临时更改</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#永久更改"><span class="nav-number">1.4.</span> <span class="nav-text">永久更改</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Ubuntu-apt更换源"><span class="nav-number">2.</span> <span class="nav-text">Ubuntu/apt更换源</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#图形界面配置（新手推荐）"><span class="nav-number">2.1.</span> <span class="nav-text">图形界面配置（新手推荐）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#手动配置"><span class="nav-number">2.2.</span> <span class="nav-text">手动配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#自动化脚本"><span class="nav-number">2.3.</span> <span class="nav-text">自动化脚本</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#树莓派Raspbian"><span class="nav-number">3.</span> <span class="nav-text">树莓派Raspbian</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#常用源"><span class="nav-number">3.1.</span> <span class="nav-text">常用源</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#更换方法"><span class="nav-number">3.2.</span> <span class="nav-text">更换方法</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Node-js-npm更换源"><span class="nav-number">4.</span> <span class="nav-text">Node.js/npm更换源</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#临时更换"><span class="nav-number">4.1.</span> <span class="nav-text">临时更换</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#永久更改-1"><span class="nav-number">4.2.</span> <span class="nav-text">永久更改</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#引用"><span class="nav-number">5.</span> <span class="nav-text">引用</span></a></li></ol>
    
    </div>
  </aside>
</section>
        
      </div>
      <footer id="footer" class="site-footer">
  

        <div class="clearfix container">
          <div class="site-info">
            &copy;
            <!-- 2019
              ex2tron&#39;s Tech Blog All Rights Reserved. -->
              Made by ex2tron | 2019
                <!-- TODO: ex2tron.wang 启用但暂时不显示访问量 2019年3月20日 -->
                <!--  -->
                  <!-- <span id="busuanzi_container_site_uv">
                    本站访客数
                    <span id="busuanzi_value_site_uv"></span>人次 本站总访问量
                    <span id="busuanzi_value_site_pv"></span>次
                  </span> -->
                  <!--  -->
          </div>
          <!-- <div class="site-credit">
            Theme by
              <a href="https://github.com/iTimeTraveler/hexo-theme-hiero" target="_blank">hiero</a>
          </div> -->
          <div>
            <p>&nbsp | 电影台词分享：
              <a href="http://moviequotes.ex2tron.wang/" style="font-weight: bold">MovieQuotes</a>
            </p>
          </div>
        </div>
</footer>


<!-- min height -->

<script>
  var contentdiv = document.getElementById("content");

  contentdiv.style.minHeight = document.body.offsetHeight - document.getElementById("allheader").offsetHeight - document.getElementById("footer").offsetHeight + "px";
</script>

<!-- Custome JS -->
<script src="/js/my.js"></script>
    </div>
    <!-- <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/categories" class="mobile-nav-link">Categories</a>
  
    <a href="/tags" class="mobile-nav-link">Tags</a>
  
    <a href="/about" class="mobile-nav-link">About</a>
  
</nav> -->
    

<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/scripts.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/main.js"></script>







  <div style="display: none;">
    <script src="https://s95.cnzz.com/z_stat.php?id=1260716016&web_id=1260716016" language="JavaScript"></script>
  </div>



	<!-- <script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"> -->
	<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
	</script>






  </div>

  <a id="rocket" href="#top" class=""></a>
  <script type="text/javascript" src="/js/totop.js" async=""></script>
</body>
</html>
